<?php
GLOBAL $CFG;
require_once('../../../config.php');
$img_path = $CFG->wwwroot.'/local/blackboxsurvey/image/';
require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/local/blackboxsurvey/lib.php');
require_once($CFG->dirroot . "/local/blackboxsurvey/forms.php");

//yeu cau login,sau khi login tu dong chuyen sang trang chu
global $USER;
if ($USER->id == null){
    $SESSION->homepage = true;
    require_login($SITE);
}
if($SESSION->homepage){
    $SESSION->homepage = null;
    redirect( $CFG->wwwroot);
}

//class
require_once($CFG->dirroot . "/local/blackboxsurvey/class/questions.php");
require_once($CFG->dirroot . "/local/blackboxsurvey/class/question_type.php");
//path
$path = $CFG->wwwroot.'/local/blackboxsurvey/admin/questionlist.php';
$path_image = $CFG->wwwroot .'/local/blackboxsurvey/image/';

//Them thanh menu ngang ung voi trang trong duong link
navigation_node::override_active_url(new moodle_url($path, array('param'=>'value')));

/* Chuan bi trang web can hien thi */	
$url = new moodle_url($path);
$PAGE->set_url($url);
$PAGE->set_title('Question List');
$PAGE->set_heading(get_string('question_management', 'local_blackboxsurvey'));
$PAGE->set_pagelayout('standard');

echo $OUTPUT->header();

//load loai cau hoi de gan header filter
$q_type = new b_question_type();
$type_filter = $q_type->get_question_type();

//tao danh sach cau hoi
$temp = new b_questions();
$str = '<div id="Filter" >'.get_string('search_question', 'local_blackboxsurvey').'<input type=text id="FilterTextBox" name="FilterTextBox" size="40"/><img onclick="clear_filter_edit_only();" style="cursor:pointer;" src="'.$path_image.'clear.jpg"/></div><br>';
$str .= $temp->create_question_table($type_filter);

/* Viet doan code cua ban o day */
$mform = new form_questionlist(null, array('str'=>$str));
$mform->display();
echo "<script type='text/javascript'>filter();</script>"; 
echo "<script type='text/javascript'>show_question_table();</script>";
/*------Ket thuc doan code cua ban-------*/
echo $OUTPUT->footer();
